package cn.hy.dataSync.element;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;

/**
 * @author tangmengyang
 */
@Data
public abstract class Column implements Serializable {

    private static final long serialVersionUID = -5703655738533270446L;

    private Type type;

    private Object rawData;

    public Column() {
    }

    public Column(final Object object, final Type type) {
        this.rawData = object;
        this.type = type;
    }

    public abstract Long asLong();

    public abstract Double asDouble();

    public abstract String asString();

    public abstract Date asDate();

    public abstract byte[] asBytes();

    public abstract Boolean asBoolean();

    public abstract BigDecimal asBigDecimal();

    public abstract BigInteger asBigInteger();

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    public enum Type {
        BAD, NULL, INT, LONG, DOUBLE, STRING, BOOL, DATE, BYTES, OBJECT
    }
}
